class Solution {
public:
    vector<int> sumZero(int n) {
        vector<int> ret(n);

        if (n % 2 == 1) {
            ret[0] = 0;
            for (int i = 1; i <= n / 2; ++i)
            {
                ret[i] = i, ret[i + n / 2] = -i;
            }
        }
        else {
            for (int i = 0; i <= n / 2 - 1; ++i)
                ret[i] = i + 1, ret[i + n / 2] = -(i + 1);
        }

        return ret;
    }
};